import Vue from "vue";
import App from "./App.vue";
import routers from "./router";
import VueRouter from "vue-router";
import store from "./store";
import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css"
import "./registerServiceWorker";
import "./common/less/common.less"

Vue.use(ElementUI)

// Vue.config.productionTip = false;

let instance = null;
let router = null;
function render(props){
  const { container } = props;

  router = new VueRouter({
      mode: "history",
      base: "/bill",// process.env.BASE_URL,
      routes:routers
  })
console.log("mount")
  instance = new Vue({
    router,
    store,
    render: h => h(App)
  }).$mount(container ? container.querySelector("#billApp") : "#billApp"); // 这里是挂载到自己的html中，基座会拿到这个挂载后的html，将其插入进去

}

if (window.__POWERED_BY_QIANKUN__) {
  __webpack_public_path__ = window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__;
}

// 独立运行微应用
if (!window.__POWERED_BY_QIANKUN__) {
  render();
}

export async function bootstrap(props){
  console.log('[vue] vue app bootstraped')
};

export async function mount(props){
  render(props)
};

export async function unmount(props){
  instance && instance.$destroy();
  instance = null;
  router = null
}


